package com.users.rn.kit.bridge

import com.users.rn.kit.bridge.RNBridge
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactContextBaseJavaModule

/**

 * 作者：wolf on 12/22/20 15:35

 * 邮箱：bluce

 */

abstract class RNBasicJavaModule<T : RNBridge> constructor(val context: ReactApplicationContext) : ReactContextBaseJavaModule(context) {

    var rnBridge: T? = null

    override fun initialize() {
        super.initialize()
        rnBridge = getBridge()
        rnBridge?.initialize(context)
    }

    override fun onCatalystInstanceDestroy() {
        super.onCatalystInstanceDestroy()
        rnBridge?.onDestroy(context)
    }

    abstract fun getBridge(): T?
}